package com.yitiao.data_algorithms.leetcode.editor.cn;

class KthMissingPositiveNumber {
    // 2022-08-21 12:38:22
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int findKthPositive(int[] arr, int k) {
            int[] array = new int[arr[arr.length - 1] + 1];

            for (int i = 0; i < arr.length; i++) {
                array[arr[i]] = 1;
            }
            int index = 0;
            for (int i = 1; i < array.length; i++) {
                if (array[i] == 0) {
                    index++;
                }
                if (index == k) {
                    return i;
                }
            }
            return k - index + arr[arr.length - 1];
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}